import type { OrderDetail } from '@/types/medicine'
import type { OrderPre, AddressItem } from '@/types/order'
import { request } from '@/utils/request'

/**
 * 查询药品订单预支付信息
 * @param params 查询参数
 * @returns Promise
 */
export const getMedicalOrderPre = (params: { prescriptionId: string }) => {
  return request.get<OrderPre>('/patient/medicine/order/pre', { params })
}
  

/**
 * 获取收货地址列表
 * @returns Promise
 */
export const getAddressList = () => {
  return request.get<AddressItem[]>('/patient/order/address')
}

/**
 *  创建药品订单
 * @param data 
 * @returns Promise
 */
export const createMedicalOrder = (data: { id: string; addressId: string; couponId?: string }) => {
  return request.post<{ id: string }>('/patient/medicine/order', data)
}

/**
 * 获取药品订单详情
 * @param id 
 * @returns Promise
 */
export const getMedicalOrderDetail = (id: string) =>
  request.get<OrderDetail>(`/patient/medicine/order/detail/${id}`)

